package com.luyuan.web.controller.gallery;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.luyuan.common.annotation.Log;
import com.luyuan.common.core.controller.BaseController;
import com.luyuan.common.core.domain.AjaxResult;
import com.luyuan.common.enums.BusinessType;
import com.luyuan.gallery.domain.ExhiGalleryViews;
import com.luyuan.gallery.service.IExhiGalleryViewsService;
import com.luyuan.common.utils.poi.ExcelUtil;
import com.luyuan.common.core.page.TableDataInfo;

/**
 * 展厅观看记录Controller
 * 
 * @author luyuan
 * @date 2025-11-13
 */
@RestController
@RequestMapping("/gallery/views")
public class ExhiGalleryViewsController extends BaseController {
    @Autowired
    private IExhiGalleryViewsService exhiGalleryViewsService;

    /**
     * 查询展厅观看记录列表
     */
    @PreAuthorize("@ss.hasPermi('gallery:views:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExhiGalleryViews exhiGalleryViews) {
        startPage();
        List<ExhiGalleryViews> list = exhiGalleryViewsService.selectExhiGalleryViewsList(exhiGalleryViews);
        return getDataTable(list);
    }

    /**
     * 导出展厅观看记录列表
     */
    @PreAuthorize("@ss.hasPermi('gallery:views:export')")
    @Log(title = "展厅观看记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExhiGalleryViews exhiGalleryViews) {
        List<ExhiGalleryViews> list = exhiGalleryViewsService.selectExhiGalleryViewsList(exhiGalleryViews);
        ExcelUtil<ExhiGalleryViews> util = new ExcelUtil<ExhiGalleryViews>(ExhiGalleryViews.class);
        util.exportExcel(response, list, "展厅观看记录数据");
    }

    /**
     * 获取展厅观看记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('gallery:views:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(exhiGalleryViewsService.selectExhiGalleryViewsById(id));
    }

    /**
     * 新增展厅观看记录
     */
    @PreAuthorize("@ss.hasPermi('gallery:views:add')")
    @Log(title = "展厅观看记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExhiGalleryViews exhiGalleryViews) {
        return toAjax(exhiGalleryViewsService.insertExhiGalleryViews(exhiGalleryViews));
    }

    /**
     * 修改展厅观看记录
     */
    @PreAuthorize("@ss.hasPermi('gallery:views:edit')")
    @Log(title = "展厅观看记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExhiGalleryViews exhiGalleryViews) {
        return toAjax(exhiGalleryViewsService.updateExhiGalleryViews(exhiGalleryViews));
    }

    /**
     * 删除展厅观看记录
     */
    @PreAuthorize("@ss.hasPermi('gallery:views:remove')")
    @Log(title = "展厅观看记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(exhiGalleryViewsService.deleteExhiGalleryViewsByIds(ids));
    }
}
